package com.example.friend.controller;

import com.example.core.controller.BaseController;
import com.example.core.domain.R;
import com.example.core.domain.TableDataInfo;
import com.example.friend.domain.dto.ExamDTO;
import com.example.friend.domain.dto.ExamQueryDTO;
import com.example.friend.domain.dto.ExamQuestionDTO;
import com.example.friend.domain.vo.ExamBaseInfo;
import com.example.friend.service.impl.ExamServiceImpl;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/exam")
public class ExamController extends BaseController {

    @Autowired
    private ExamServiceImpl examService;

    @GetMapping("/semiLogin/list")
    public TableDataInfo list(@RequestBody ExamDTO examDTO) {
        return  examService.list(examDTO);
    }

//    @GetMapping("/semiLogin/redis/list")
//    public TableDataInfo redisList(@RequestBody ExamQueryDTO examQueryDTO) {
//        return getDataTable( examService.redisList(examQueryDTO));
//    }

    @Operation(summary = "竞赛列表")
    @GetMapping("/history/list")
    public TableDataInfo historyList(ExamDTO searchDTO) {
        return examService.selectHistoryExamList(searchDTO);
    }


    @Operation(summary = "竞赛题目信息")
    @GetMapping("/examQuestion/list")
    public TableDataInfo examQuestionList(ExamQuestionDTO examQuestionDTO) {
        return examService.examQuestionList(examQuestionDTO);
    }

    @Operation(summary = "查看竞赛排行榜")
    @GetMapping("/rank/list")
    public TableDataInfo rankList(ExamDTO examDTO)  {
        return examService.rankList(examDTO);
    }


    @Operation(summary = "查看竞赛基本信息")
    @GetMapping("/baseInfo")
    @Parameters({@Parameter(name = "examId",description = "竞赛id")})
    public R<ExamBaseInfo> baseInfo(Long examId) {
        return R.ok(examService.baseInfo(examId));
    }
}
